<template>
  <div class="f-all">
    <van-nav-bar title="报警记录" left-text="返回" left-arrow @click-left="onClickLeft" />

    <div class="f-all1">
      <div class="two-bottom-bottom2">
        <div class="two-bottom-bottom2-zi">预警监测</div>
        <div class="two-bottom-bottom3">
          <div class="two-bottom-bottom3-1">
            <div class="ltwo-bottom-bottom3-1-top">{{ this.lalarm.alarminfoNum }}</div>
            <div class="ltwo-bottom-bottom3-1-bottem">累计预警数</div>
          </div>
          <div class="two-bottom-bottom3-1">
            <div class="ltwo-bottom-bottom3-1-top">{{ this.lalarm.alarminfoDealNum }}</div>
            <div class="ltwo-bottom-bottom3-1-bottem">已处理预警数</div>
          </div>
          <div class="two-bottom-bottom3-2">
            <div class="ltwo-bottom-bottom3-1-top">{{ this.lalarm.alarminfoNoDealNum }}</div>
            <div class="ltwo-bottom-bottom3-1-bottem">未处理预警数</div>
          </div>
        </div>

        <div class="two-bottom-bottom4">
          <div class="two-bottom4-top1">设备名称</div>
          <div class="two-bottom4-top2">预警时间</div>

          <div class="two-bottom4-top3">预警状态</div>
        </div>
        <div class="two-bottom4-bottom">
          <div class="father-cont-bottom">
            <ul class="fa-scroll-cont" id="scroll-box2">
              <li v-for=" item in police_xinxi" :key="item.name">
                <span class="f-hua1-bottom">{{item.equipment_name}}</span>
                <span class="f-hua2-bottom">{{item.alarminfo_start}}</span>
                <span class="f-hua3-bottom">
                  <span v-if="item.alarminfo_status==0" style="color:red">未处理</span>
                  <span v-if="item.alarminfo_status==1" style="color:blue">已处理</span>
                </span>
              </li>
            </ul>
          </div>
        </div>
      </div>
    </div>
    <div class="two-bottom-bottom2-zi">报警信息</div>
    <div class="f-all2">
         <div class="all2-1-1">监控设备</div>
      <div class="bao">
        <!-- <div class="two-zi">监控设备报警信息</div> -->
      
        <div class="all2-1">
          <div class="all2-11">设备总数: <span style="color:brown">{{this.monitorNum}}</span></div>
          <div class="all2-12">运行总数: <span style="color:brown"> {{this.monitorIngNum}}</span></div>
        </div>
        <div class="all2-1">
          <div class="all2-11">今日预警: <span style="color:brown">{{this.monitorWaringNum}}</span></div>
          <div class="all2-12">已处理: <span style="color:brown">{{this.monitorDealNum}}</span></div>
        </div>
      </div>
    </div>
    <div class="f-all2">
         <div class="all2-1-1">环境监测</div>
      <div class="bao">
        <!-- <div class="two-zi">监控设备报警信息</div> -->
      
        <div class="all2-1">
          <div class="all2-11">设备总数:
              <span style="color:brown">{{this.weatherNum}}</span>
          </div>
          <div class="all2-12">运行总数: <span style="color:brown">{{this.weatherIngNum}}</span></div>
        </div>
        <div class="all2-1">
          <div class="all2-11">今日预警: <span style="color:brown">{{this.weatherWaringNum}}</span></div>
          <div class="all2-12">已处理: <span style="color:brown">{{this.weatherDealNum}}</span></div>
        </div>
      </div>
    </div>
   <div class="f-all2">
         <div class="all2-1-1">塔吊设备</div>
      <div class="bao">
        <!-- <div class="two-zi">监控设备报警信息</div> -->
      
        <div class="all2-1">
          <div class="all2-11">设备总数: <span style="color:brown">{{this.towerNum}}</span></div>
          <div class="all2-12">运行总数: <span style="color:brown">{{this.towerIngNum}}</span></div>
        </div>
        <div class="all2-1">
          <div class="all2-11">今日预警: <span style="color:brown">{{this.towerWaringNum}}</span></div>
          <div class="all2-12">已处理: <span style="color:brown">{{this.towerDealNum}}</span></div>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import http from '../api';
export default {
  data() {
    return {
         //塔吊设备数据
      towerIngNum:"",
      towerNum:"",
      towerWaringNum:"",
      towerDealNum:"",
      // 环境监测设备数据
      weatherNum:"",
      weatherIngNum:"",
      weatherWaringNum:"",
      weatherDealNum:"",
      // 监控设备
      monitorNum:"",
      monitorIngNum:"",
      monitorWaringNum:"",
      monitorDealNum:"",
      police_xinxi: [],
      lalarm: [], //监控大屏大图下面的预警监测
    };
  },
  mounted() {
       // 获取塔吊设备数据
    http.getTowerNum({}).then((res) => {
      console.log("塔吊设备", res);
      
      this.towerIngNum=res.data.towerIngNum
      this.towerNum=res.data.towerNum
      this.towerWaringNum=res.data.towerWaringNum
      this.towerDealNum=res.data.towerDealNum
    });
    // 获取环境监测设备数据
    http.getWeatherNum({}).then((res) => {
      console.log("环境监测设备", res);
      
      this.weatherNum=res.data.weatherNum
      this.weatherIngNum=res.data.weatherIngNum
      this.weatherWaringNum=res.data.weatherWaringNum
      this.weatherDealNum=res.data.weatherDealNum
    });
    // 获取监控设备数据
    http.getMonitorNum({}).then((res) => {
      console.log("监控设备", res);
      
      this.monitorNum=res.data.monitorNum
      this.monitorIngNum=res.data.monitorIngNum
      this.monitorWaringNum=res.data.monitorWaringNum
      this.monitorDealNum=res.data.monitorDealNum
    });
    //监控大屏大图下面的工程进度图
    http.getAlarminfoNum({}).then((res) => {
      console.log('监控大屏大图下面的工程进度图', res.data);
      this.lalarm = res.data;
    });
    // 获取预警信息的向上滑动 http.getAlarminfoNum
    http.getAlarminfoNum({}).then((r) => {
      console.log('预警监测向上', r);
      this.police_xinxi = r.data.buildAlarminfoList;
      console.log('yyyyyyyyy', this.police_xinxi);
    });
    // 自动向上翻转2
    this.scroll2();
  },
  methods: {
    onClickLeft() {
      this.$router.push({
        name: '主页',
      });
    },
    // 动起来2222222222222222222222222222222222222222
    scroll2() {
      const dom2 = document.getElementById('scroll-box2');
      const that = this;
      let timer = null;
      const animationEndHandler = (evt) => {
        const dom2 = document.getElementById('scroll-box2');
        dom2.style.cssText = 'transform:translate(0,0)';
        dom2.appendChild(dom2.children[0]); //把第一个DOM添加到最后一个去
      };
      const mouseEnterHander = (evt) => {
        clearInterval(timer);
      };
      const initInterval = () => {
        timer = setInterval(() => {
          if (dom2.children[0]) {
            let scrollHeight = dom2.children[0].offsetHeight;
            scrollHeight = parseInt(scrollHeight);
            dom2.style.cssText = `transform:translate(0px,-${
              scrollHeight + 10
            }px);transition:all 1s ease;`;
          }
        }, 1000);
      };
      const mouseLeaveHandler = () => {
        initInterval();
      };
      dom2.addEventListener('mouseenter', mouseEnterHander);
      dom2.addEventListener('mouseleave', mouseLeaveHandler);
      dom2.removeEventListener('transitionend', animationEndHandler);
      dom2.addEventListener('transitionend', animationEndHandler); //只要监听到translate就会执行,这样就能一直动了
      initInterval();
    },
  },
};
</script>
<style scoped>
.f-all {
  width: 100%;
  height: 80rem;
}
.f-all2 {
  width: 100%;
  /* margin-top: 1rem; */
  /* height: 45rem; */
  /* background-color: lightpink; */
  border-bottom: 1px solid gainsboro;
  display: flex;
}
.all2-1 {
  width: 100%;
  height: 5rem;
  display: flex;
  /* background-color: rgb(117, 110, 111); */
}
.bao {
    width: 75%;
  margin-left: 3rem;
}
.all2-1-1 {
  width: 25%;
  height: 8.5rem;
  border-radius: 50%;
  background-color: rgba(63, 114, 186, 0.7);
  color: white;
  margin-top: 1rem;
  line-height: 9rem;
  font-size: 1.7rem;
  text-align: center;
  display: inline-block;
}
.all2-11 {
  width: 12rem;
  height: 2rem;
  font-size: 1.7rem;
  /* margin-left: 7rem; */
  margin-top: 1rem;
  display: inline-block;
  /* background-color: lightpink; */
}
.all2-12 {
  width: 10rem;
  height: 2rem;
  font-size: 1.7rem;
  margin-left: 3rem;
  margin-top: 1rem;
  display: inline-block;
  /* background-color: lightpink; */
}
.two-zi {
  background-color: rgb(137, 180, 207);
  font-size: 1.8rem;
  height: 3rem;
  line-height: 3rem;
  /* margin-top: 1rem; */
  font-family: 600;
  /* margin-left: 1rem; */
  color: rgb(255, 255, 255);
  /* line-height: 2.3rem; */
}
.f-all1 {
  width: 100%;
  /* background-color: lightcoral; */
  margin-top: 0.5rem;
}
.two-bottom-bottom2 {
  width: 100%;
  /* height: 420px; */
  /* border-radius: 15px; */
  /* margin-left: 15px; */
  /* border: 1px solid #072e79; */
}
.two-bottom-bottom2-zi {
  /* color: rgb(255, 255, 255); */

  font-size: 1.8rem;
  height: 2.5rem;
  margin-top: 1rem;
  /* font-weight: 600; */
  /* background-color: rgba(14, 64, 134, 0.8); */
  /* margin-top: 10px;
  margin-left: 15px; */
  /* font-style: italic; */
  font-weight: 700;
}

.two-bottom-bottom3 {
  /* width: 98%; */
  height: 9rem;
  margin: 0 auto;
  /* background-color: wheat; */
  margin-top: 10px;
  /* margin-left: 3px; */
  display: flex;
}
.two-bottom-bottom3-1 {
  width: 30%;
  height: 9rem;
  margin-left: 0.5rem;
  background: rgba(63, 114, 186, 0.7);
}
.ltwo-bottom-bottom3-1-top {
  color: rgb(243, 243, 243);
  font-size: 2rem;
  /* height: 39px; */
  margin-top: 1.7rem;
  line-height: 3.6rem;
  text-align: center;
}
.ltwo-bottom-bottom3-1-bottem {
  width: 90%;
  margin: 0 auto;
  color: rgb(255, 255, 255);
  font-size: 1.4rem;
  text-align: center;
  /* background-color: lightskyblue; */
  /* line-height: 35px; */
}
.two-bottom-bottom3-2 {
  width: 33%;
  height: 9rem;
  margin-left: 0.5rem;
  background-color: #672129;
}
.two-bottom-bottom4 {
  /* width: 90%; */
  height: 4rem;
  /* margin-left: 20px; */
  /* background-color: #072e79; */
  display: flex;
  font-size: 1.4rem;
  /* margin-left: 1rem; */
  color: #4c74ad;
  /* color: white; */

  /* border: 1px solid #072e79; */
}
.two-bottom4-top1 {
  margin-top: 1rem;
  /* margin-left: 20px; */
  /* font-size: 13px; */
  margin-left: 0.5rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.two-bottom4-top2 {
  margin-top: 1rem;
  margin-left: 9.1rem;
}
.two-bottom4-top3 {
  margin-top: 1rem;
  margin-left: 9rem;
}
.f-hua1-bottom {
  display: inline-block;
  width: 13rem;
  margin-top: 5px;
  padding-left: 3px;
  font-size: 14px;
  /* 字变成...的样式代码 */
  /* overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; */
  /* background-color: wheat; */
}
.f-hua2-bottom {
  display: inline-block;
  width: 13rem;
  font-size: 14px;
  margin-left: 1rem;
  /* background-color: wheat; */
}
.f-hua3-bottom {
  display: inline-block;
  font-size: 14px;
  /* width: 240px; */
  margin-left: 1.5rem;
  /* 字变成...的样式代码 */
  /* overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap; */
  /* width: 70px; */
  /* background-color: wheat; */
}
.father-cont-bottom {
  margin: 0;
  padding: 0;
  /* height: 250px; */
  /* background-color: lightskyblue; */
  width: 95%;
  overflow: hidden;
  margin-left: 7px;
}
li {
  /* width: 100%; */
  cursor: pointer;
  height: 3rem;
  /* color: #95adce; */
  /* padding: 10px auto; */
  background-color: rgba(63, 114, 186, 0.7);
  margin-top: 10px;
  color: #ffffff;
  /* border-bottom: 1px solid #999999; */
}
</style>